<?php
session_start();
require('dbconnect.php');
$question=$_POST['question'];
$answer=$_POST['answer'];
$username=$_SESSION['userName'];

$checksql="select * from user where name='$username'";
$check_re=mysql_query($checksql,$conn);
$num=mysql_num_rows($check_re);
$sql="update user set s_question='$question',s_answer='$answer' where name='$username'";
mysql_query($sql,$conn) or die("插入数据错误: ".mysql_error());
mysql_close($conn);
echo ("<script type='text/javascript'> alert('Success!'); location.href='index.php';</script>");
?>